package sam.learning.ribbon.consumer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import sun.misc.Unsafe;

import java.util.logging.Logger;


/**
 * @Author taozhaoyang
 * @Description //TODO $
 * @Date 2018/8/22 15:46
 **/

@RestController
public class HelloController {


    private final Logger logger = Logger.getLogger(String.valueOf(getClass()));

    @Autowired
    private DiscoveryClient client;


    @RequestMapping("/hello")
    public  String index(){

        ServiceInstance serviceInstance =  client.getLocalServiceInstance();
        logger.info("/hello,host:"+serviceInstance.getHost()+",service_id:"+serviceInstance.getServiceId());
        return "Hello,world!";
    }


}
